/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.ipccenter.toster.jpa;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.*;

/**
 *
 * @author 7
 */
@Entity
@Table(name = "TESTS")

public class JPATest implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected JPATestPK testsPK;
    @Column(name = "ANSWER_ID")
    private Short answerId;
    @Column(name = "MARK")
    private Short mark;
    @JoinColumn(name = "SESSION_ID", referencedColumnName = "SESSION_ID", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private JPASession sessions;

    public JPATest() {
    }

    public JPATest(JPATestPK testsPK) {
        this.testsPK = testsPK;
    }

    public JPATest(BigInteger sessionId, BigInteger tcId) {
        this.testsPK = new JPATestPK(sessionId, tcId);
    }

    public JPATestPK getTestsPK() {
        return testsPK;
    }

    public void setTestsPK(JPATestPK testsPK) {
        this.testsPK = testsPK;
    }

    public Short getAnswerId() {
        return answerId;
    }

    public void setAnswerId(Short answerId) {
        this.answerId = answerId;
    }

    public Short getMark() {
        return mark;
    }

    public void setMark(Short mark) {
        this.mark = mark;
    }

    public JPASession getSessions() {
        return sessions;
    }

    public void setSessions(JPASession sessions) {
        this.sessions = sessions;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (testsPK != null ? testsPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof JPATest)) {
            return false;
        }
        JPATest other = (JPATest) object;
        if ((this.testsPK == null && other.testsPK != null) || (this.testsPK != null && !this.testsPK.equals(other.testsPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.ipccenter.toster.jpa.Tests[ testsPK=" + testsPK + " ]";
    }
    
}
